package com.gome.oa.custom;

import com.gome.oa.dialog.PopupBrowserDialog;
import com.gome.oa.handler.BrowserDialogHandler;
import com.teamdev.jexplorer.Browser;
import com.teamdev.jexplorer.BrowserContext;
import com.teamdev.jexplorer.JSValue;

/**
*
* @author: tang li
* @date: 2016年8月13日
* @desc: 
*
*/
public class GMBrowser extends Browser {

	private static final long serialVersionUID = -8149243722312377636L;
	
	private volatile boolean allowExecJs = true;
	
	private PopupBrowserDialog popupDialog;
	
	public GMBrowser(BrowserContext context) {
		super(context);
	}

	public boolean isAllowExecJs() {
		return allowExecJs;
	}

	public void setAllowExecJs(boolean allowExecJs) {
		this.allowExecJs = allowExecJs;
	}
	
	public JSValue executeScript2(String js) {
		if(!allowExecJs) {
			return null;
		}
		return super.executeScript(js);
	}

	public void setOwner(PopupBrowserDialog popupDialog) {
		this.popupDialog = popupDialog;
		this.setDialogHandler(new BrowserDialogHandler(this, this.popupDialog));
	}
}
